<?php
declare (strict_types = 1);

namespace app\middleware;

use app\common\tools\ApiRequestInfo;

class Api
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {

        $info = ApiRequestInfo::instance();
        $info->setAccessToken($request->header('access-token', ''));
        $info->setDevice($request->header('device', ''));
        $info->setDeviceHeight($request->header('device-height', ''));
        $info->setDeviceType($request->header('device-type', ''));
        $info->setDeviceWidth($request->header('device-width', ''));
        $info->setReqTime($request->header('req-time', ''));
        $info->setLang($request->header('lang', ''));
        $info->setSysVersion($request->header('sys-version', ''));
        $info->setUuid($request->header('uuid', ''));
        $info->setAppVersion($request->header('app-version', '100'));

        return $next($request);
    }
}
